﻿<UserControl x:Class="Sautom.Modules.Client.Controls.ClientInfoEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:res="clr-namespace:Sautom.I18N;assembly=Sautom.I18N" 
             xmlns:l="clr-namespace:Sautom.ClientComunication.Converters;assembly=Sautom.ClientComunication"
             xmlns:Helpers="clr-namespace:Sautom.ClientComunication.Helpers;assembly=Sautom.ClientComunication"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <l:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" /> 
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="371*" />
            <ColumnDefinition Width="371*" />
        </Grid.ColumnDefinitions>
        <Border BorderBrush="Azure" BorderThickness="3">
            <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top">
                <Label Content="{Binding Source={x:Static res:ClientResources.FirstNameLabel}}" />
                <TextBox Text="{Binding FirstName, UpdateSourceTrigger=PropertyChanged}" Helpers:TextBoxMasking.Mask="^[А-Яа-я]+$" />
                <TextBlock Visibility="{Binding IsFirstNameError, Converter={StaticResource BoolToVisibilityConverter}}" Text="Поле обязательно" Foreground="Red" />
            	<Label Content="{Binding Source={x:Static res:ClientResources.LastNameLabel}}" />
                <TextBox Text="{Binding LastName, UpdateSourceTrigger=PropertyChanged}" Helpers:TextBoxMasking.Mask="^[А-Яа-я]+$"/>
                <TextBlock Visibility="{Binding IsLastNameError, Converter={StaticResource BoolToVisibilityConverter}}" Text="Поле обязательно" Foreground="Red" />
                <Label Content="{Binding Source={x:Static res:ClientResources.MiddleNameLabel}}" />
                <TextBox Text="{Binding MiddleName, UpdateSourceTrigger=PropertyChanged}" Helpers:TextBoxMasking.Mask="^[А-Яа-я]+$" />
                <TextBlock Visibility="{Binding IsMiddleNameError, Converter={StaticResource BoolToVisibilityConverter}}" Text="Поле обязательно" Foreground="Red" />
                <Label Content="{Binding Source={x:Static res:ClientResources.NameEnLabel}}" />
                <TextBox Text="{Binding NameLat, UpdateSourceTrigger=PropertyChanged}" Helpers:TextBoxMasking.Mask="^[A-Za-z]+$"/>
                <Label Content="{Binding Source={x:Static res:ClientResources.BirthDateLabel}}" />
                <DatePicker SelectedDate="{Binding BirthDate, UpdateSourceTrigger=PropertyChanged}" />                
                <Label Content="{Binding Source={x:Static res:ClientResources.PersonalNumberLabel}}" />
                <TextBox Text="{Binding PersonalNumber, UpdateSourceTrigger=PropertyChanged}" Helpers:TextBoxMasking.Mask="^[0-9]{0,4}[A-Za-z]{0,2}[0-9]{0,4}$" />
                
                <Label Content="{Binding Source={x:Static res:ClientResources.PassportInfoLabel}}" />
                <TextBox Text="{Binding PassportInfo, UpdateSourceTrigger=PropertyChanged}"  Helpers:TextBoxMasking.Mask="^[A-Za-z]{0,2}[0-9]{0,7}$" />

                <Label Content="{Binding Source={x:Static res:ClientResources.PassportByWhomLabel}}" />
                <TextBox Text="{Binding PassportByWhom, UpdateSourceTrigger=PropertyChanged}" />
                <Label Content="{Binding Source={x:Static res:ClientResources.PassportFromDateLabel}}" />
                <DatePicker SelectedDate="{Binding PassportFromDate, UpdateSourceTrigger=PropertyChanged}" DisplayDateEnd="{Binding PassportByDate}" />
                <Label Content="{Binding Source={x:Static res:ClientResources.PassportByDateLabel}}" />
                <DatePicker SelectedDate="{Binding PassportByDate, UpdateSourceTrigger=PropertyChanged}" DisplayDateStart="{Binding PassportFromDate}" />

                <Label Content="{Binding Source={x:Static res:ClientResources.AddressLabel}}" />
                <TextBox MinHeight="50" TextWrapping="Wrap" AcceptsReturn="True" Text="{Binding Address, UpdateSourceTrigger=PropertyChanged}" Helpers:TextBoxMasking.Mask="^[А-Яа-я0-9,()/\s\t\n]+$" />
                <Label Content="{Binding Source={x:Static res:ClientResources.PhoneFirstLabel}}" />
                <TextBox Text="{Binding PhoneFirst, UpdateSourceTrigger=PropertyChanged}" />
                <Label Content="{Binding Source={x:Static res:ClientResources.PhoneSecondLabel}}" />
                <TextBox Text="{Binding PhoneSecond, UpdateSourceTrigger=PropertyChanged}" />
            </StackPanel>
        </Border>
        <Border Grid.Column="1" BorderBrush="Azure" BorderThickness="3">
            <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Visibility="{Binding IsParentSection, Converter={StaticResource ResourceKey=BoolToVisibilityConverter}}">
                <Label Content="{Binding Source={x:Static res:ClientResources.ParentNameLabel}}" />
                <TextBox Text="{Binding ParentName, UpdateSourceTrigger=PropertyChanged}" />
                <Label Content="{Binding Source={x:Static res:ClientResources.ParentAddressLabel}}" />
                <TextBox MinHeight="50" TextWrapping="Wrap" AcceptsReturn="True" Text="{Binding ParentAddress, UpdateSourceTrigger=PropertyChanged}" />
                <Label Content="{Binding Source={x:Static res:ClientResources.ParentPhoneLabel}}" />
                <TextBox Text="{Binding ParentPhone, UpdateSourceTrigger=PropertyChanged}" />
                <Label Content="{Binding Source={x:Static res:ClientResources.ParentPassportInfoLabel}}" />
                <TextBox Text="{Binding ParentPassportInfo, UpdateSourceTrigger=PropertyChanged}" />
            </StackPanel>
        </Border>
    </Grid>
</UserControl>
